package com.wzh.store.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzh.store.entity.District;
import com.wzh.store.mapper.DistrictMapper;
import com.wzh.store.service.IDistrictService;
import org.apache.ibatis.jdbc.Null;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author wzh
 * @create 2022/4/23 13:47
 * @Description：
 */
@Service
public class DistrictServiceimpl extends ServiceImpl<DistrictMapper, District> implements IDistrictService {
     @Autowired
    public DistrictMapper districtMapper; 

    @Override
    public List<District> getByParent(String parent) {
        List<District> list = districtMapper.findByParent(parent);
//        将无需使用的字段设置为空可以节省流量和提升效率等
        for (District district : list) {
            district.setId(null);
            district.setParent(null);
        }
        return list;
    }

    @Override
    public String getNameByCode(String code) {
        String name = districtMapper.findNameByCode(code);
        return name;
    }
}
